package com.xuxin.baby.presenter;

import com.xuxin.baby.bean.BaseBean;
import com.xuxin.baby.bean.KeywordsBean;
import com.xuxin.baby.contract.SearchContract;
import com.xuxin.baby.model.SearchModel;

/**
 * Created by xu_xin
 * Created on 2020/10/23 0023
 * 搜索
 */
public class SearchPresenter implements SearchContract.Presenter {
    private  final SearchModel model;
    private final  SearchContract.View view;

    public SearchPresenter(SearchContract.View view) {
        this.view = view;
        model = new SearchModel();
    }

    @Override
    public void getKeywords(String tenantId, String token,String memberId) {
        if (null != model) {
            model.getKeywords(this, tenantId,  token, memberId);
        }
    }

    @Override
    public void onSuccess(KeywordsBean keywordsBean) {
        if (null != view) {
            view.onSuccess(keywordsBean);
        }
    }

    /**
     * 以下内容复用(用于请求完成后的操作)
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}